package org.itboys.core.controller.front.small;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.itboys.commons.utils.tools.ListUtil;
import org.itboys.core.dto.scene.SundaySceneDto;
import org.itboys.core.entity.mongo.SundayAddress;
import org.itboys.core.service.mongo.front.SundayFrontSceneService;
import org.itboys.core.util.ResponseMessage;
import org.itboys.framework.spring.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 作者：zzq
 * 时间：2018/10/22
 * 描述：场景
 */
@Controller
@RequestMapping("/sunday/small/scene")
@Api(value = "scene", description = "场景")
public class SundaySmallSceneController extends BaseController {
    @Autowired
    private SundayFrontSceneService sceneService;

    @RequestMapping(value = "/select", method = {RequestMethod.POST})
    @ApiOperation(value = "获取所有场景")
    public void select(
            HttpServletRequest request,
            HttpServletResponse response
    ) {
        List<SundaySceneDto> result = sceneService.select();
        ResponseMessage.success(result);
    }

    /**
     *
     * @param request
     * @param response
     * @param sceneId
     * @throws IOException
     */
    @RequestMapping(value = "/findOne", method = {RequestMethod.POST})
    @ApiOperation(value = "获取单个场景")
    public void findOne(
            HttpServletRequest request,
            HttpServletResponse response,
            @ApiParam(value = "场景Id") @RequestParam(value = "sceneId", required = true) Long sceneId
    ){
        SundaySceneDto result = sceneService.findOne(sceneId);
        ResponseMessage.success(result);
    }
}
